package com.DB.redis;

import redis.clients.jedis.Jedis;

import java.util.Iterator;
import java.util.List;
import java.util.Set;

public class Demo1 {
    public static void main(String[] args) {
        Jedis jedis = new Jedis("127.0.0.1");

        //1 base
        jedis.set("username", "liyan");
        System.out.println(jedis.get("username")+"-is the username");

        //2 list
        jedis.lpush("mobile-phone", "Iphone");
        jedis.lpush("mobile-phone", "HTC");
        jedis.lpush("mobile-phone", "Samsung");
        List<String> phoneList = jedis.lrange("mobile-phone", 0, 2);
        for (String str : phoneList)
            System.out.print(str + " ");
        System.out.println();

        //获取Key
        Set<String> keys = jedis.keys("*");
        Iterator<String> it = keys.iterator();
        while (it.hasNext()) {
            System.out.println(it.next());
        }


    }
}
